xen/compiler: import 'fallthrough' keyword from linux
authorRahul Singh <rahul.singh@arm.com>
Wed, 20 Jan 2021 14:52:41 +0000 (14:52 +0000)
committerJulien Grall <jgrall@amazon.com>
Sat, 23 Jan 2021 11:48:33 +0000 (11:48 +0000)
commitbe5dc0b90db68df57925ee951ccc480fcab14192
tree4239677abec15d1fc4f20e89d74c959132ceba97
parent51b444f84a21e71b2e7d642ac5fc2afde19f379c
xen/compiler: import 'fallthrough' keyword from linux

-Wimplicit-fallthrough warns when a switch case falls through. Warning
can be suppress by either adding a /* fallthrough */ comment, or by
using a null statement: __attribute__ ((fallthrough))

Define the pseudo keyword 'fallthrough' for the ability to convert the
various case block /* fallthrough */ style comments to null statement
"__attribute__((__fallthrough__))"

In C mode, GCC supports the __fallthrough__ attribute since 7.1,
the same time the warning and the comment parsing were introduced.

fallthrough devolves to an empty "do {} while (0)" if the compiler
version (any version less than gcc 7) does not support the attribute.

Signed-off-by: Rahul Singh <rahul.singh@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
xen/include/xen/compiler.h